const {
	Controller
} = require('uni-cloud-router')
const uniID = require('uni-id')
module.exports = class StatisticsController extends Controller {
	async getMemberBuyCount() {
		const {
			categoryId,
			pageNum,
			pageSize
		} = this.ctx.data
		// if (!userId) {
		// 	return {
		// 		code: 500,
		// 		msg: "参数错误"
		// 	}
		// }
		try{
			let res = await this.service.statistics.getMemberBuyCount({
				categoryId,
				pageNum,
				pageSize
			})
			return {
				code: 200,
				result: res
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
	
	//订单统计导出
	async outOrderList() {
		const {
			categoryId
		} = this.ctx.data
		try{
			let res = await this.service.statistics.outOrderList({
				categoryId
			})
			return {
				code: 200,
				result: res
			}
		}catch(e){
			return {
				code: 500,
				msg: e.message
			}
		}
	}
}
